mirror of
				https://github.com/mermaid-js/mermaid.git
				synced 2025-10-31 02:44:17 +01:00 
			
		
		
		
	Compare commits
	
		
			11 Commits
		
	
	
		
			@mermaid-j
			...
			UpdateClas
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
|   | de6add6f0e | ||
|   | f1a6ef11f0 | ||
|   | 67ff83a8b4 | ||
|   | c323293fe9 | ||
|   | dc1308a2b9 | ||
|   | 65c0c0acb7 | ||
|   | 96e5151aec | ||
|   | 7a987a22c1 | ||
|   | 824feb544d | ||
|   | ada4ddc60d | ||
|   | 6d0794130c | 
| @@ -522,6 +522,7 @@ export const insertEdge = function (elem, e, edge, clusterDb, diagramType, graph | |||||||
|     default: |     default: | ||||||
|       strokeClasses = ''; |       strokeClasses = ''; | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   switch (edge.pattern) { |   switch (edge.pattern) { | ||||||
|     case 'solid': |     case 'solid': | ||||||
|       strokeClasses += ' edge-pattern-solid'; |       strokeClasses += ' edge-pattern-solid'; | ||||||
| @@ -586,6 +587,9 @@ export const insertEdge = function (elem, e, edge, clusterDb, diagramType, graph | |||||||
|     case 'extension': |     case 'extension': | ||||||
|       svgPath.attr('marker-start', 'url(' + url + '#' + diagramType + '-extensionStart' + ')'); |       svgPath.attr('marker-start', 'url(' + url + '#' + diagramType + '-extensionStart' + ')'); | ||||||
|       break; |       break; | ||||||
|  |     case 'realization': | ||||||
|  |       svgPath.attr('marker-start', 'url(' + url + '#' + diagramType + '-realizationStart' + ')'); | ||||||
|  |       break; | ||||||
|     case 'composition': |     case 'composition': | ||||||
|       svgPath.attr('marker-start', 'url(' + url + '#' + diagramType + '-compositionStart' + ')'); |       svgPath.attr('marker-start', 'url(' + url + '#' + diagramType + '-compositionStart' + ')'); | ||||||
|       break; |       break; | ||||||
| @@ -616,6 +620,9 @@ export const insertEdge = function (elem, e, edge, clusterDb, diagramType, graph | |||||||
|     case 'extension': |     case 'extension': | ||||||
|       svgPath.attr('marker-end', 'url(' + url + '#' + diagramType + '-extensionEnd' + ')'); |       svgPath.attr('marker-end', 'url(' + url + '#' + diagramType + '-extensionEnd' + ')'); | ||||||
|       break; |       break; | ||||||
|  |     case 'realization': | ||||||
|  |       svgPath.attr('marker-end', 'url(' + url + '#' + diagramType + '-realizationEnd' + ')'); | ||||||
|  |       break; | ||||||
|     case 'composition': |     case 'composition': | ||||||
|       svgPath.attr('marker-end', 'url(' + url + '#' + diagramType + '-compositionEnd' + ')'); |       svgPath.attr('marker-end', 'url(' + url + '#' + diagramType + '-compositionEnd' + ')'); | ||||||
|       break; |       break; | ||||||
|   | |||||||
| @@ -11,6 +11,7 @@ const insertMarkers = (elem, markerArray, type, id) => { | |||||||
|  |  | ||||||
| const extension = (elem, type, id) => { | const extension = (elem, type, id) => { | ||||||
|   log.trace('Making markers for ', id); |   log.trace('Making markers for ', id); | ||||||
|  |  | ||||||
|   elem |   elem | ||||||
|     .append('defs') |     .append('defs') | ||||||
|     .append('marker') |     .append('marker') | ||||||
| @@ -38,6 +39,36 @@ const extension = (elem, type, id) => { | |||||||
|     .attr('d', 'M 1,1 V 13 L18,7 Z'); // this is actual shape for arrowhead |     .attr('d', 'M 1,1 V 13 L18,7 Z'); // this is actual shape for arrowhead | ||||||
| }; | }; | ||||||
|  |  | ||||||
|  | const realization = (elem, type, id) => { | ||||||
|  |   log.trace('Making markers for ', id); | ||||||
|  |  | ||||||
|  |   elem | ||||||
|  |     .append('defs') | ||||||
|  |     .append('marker') | ||||||
|  |     .attr('id', type + '-realizationStart') | ||||||
|  |     .attr('class', 'marker realization ' + type) | ||||||
|  |     .attr('refX', 18) | ||||||
|  |     .attr('refY', 7) | ||||||
|  |     .attr('markerWidth', 190) | ||||||
|  |     .attr('markerHeight', 240) | ||||||
|  |     .attr('orient', 'auto') | ||||||
|  |     .append('path') | ||||||
|  |     .attr('d', 'M 1,7 L18,13 V 1 Z'); | ||||||
|  |  | ||||||
|  |   elem | ||||||
|  |     .append('defs') | ||||||
|  |     .append('marker') | ||||||
|  |     .attr('id', type + '-realizationEnd') | ||||||
|  |     .attr('class', 'marker realization ' + type) | ||||||
|  |     .attr('refX', 1) | ||||||
|  |     .attr('refY', 7) | ||||||
|  |     .attr('markerWidth', 20) | ||||||
|  |     .attr('markerHeight', 28) | ||||||
|  |     .attr('orient', 'auto') | ||||||
|  |     .append('path') | ||||||
|  |     .attr('d', 'M 1,1 V 13 L18,7 Z'); // this is actual shape for arrowhead | ||||||
|  | }; | ||||||
|  |  | ||||||
| const composition = (elem, type) => { | const composition = (elem, type) => { | ||||||
|   elem |   elem | ||||||
|     .append('defs') |     .append('defs') | ||||||
| @@ -282,6 +313,7 @@ const barb = (elem, type) => { | |||||||
| // TODO rename the class diagram markers to something shape descriptive and semantic free | // TODO rename the class diagram markers to something shape descriptive and semantic free | ||||||
| const markers = { | const markers = { | ||||||
|   extension, |   extension, | ||||||
|  |   realization, | ||||||
|   composition, |   composition, | ||||||
|   aggregation, |   aggregation, | ||||||
|   dependency, |   dependency, | ||||||
|   | |||||||
| @@ -366,6 +366,7 @@ export const relationType = { | |||||||
|   COMPOSITION: 2, |   COMPOSITION: 2, | ||||||
|   DEPENDENCY: 3, |   DEPENDENCY: 3, | ||||||
|   LOLLIPOP: 4, |   LOLLIPOP: 4, | ||||||
|  |   REALIZATION: 5, | ||||||
| }; | }; | ||||||
|  |  | ||||||
| const setupToolTips = function (element: Element) { | const setupToolTips = function (element: Element) { | ||||||
|   | |||||||
| @@ -1193,16 +1193,18 @@ describe('given a class diagram with relationships, ', function () { | |||||||
|     }); |     }); | ||||||
|  |  | ||||||
|     it('should handle relation definitions with type only on right side', function () { |     it('should handle relation definitions with type only on right side', function () { | ||||||
|       const str = 'classDiagram\n' + 'Class1 --|> Class02'; |       const str = 'classDiagram\n' + 'Class1 --|> Class2'; | ||||||
|  |  | ||||||
|       parser.parse(str); |       parser.parse(str); | ||||||
|  |  | ||||||
|       const relations = parser.yy.getRelations(); |       const relations = parser.yy.getRelations(); | ||||||
|  |       const class1 = parser.yy.getClass('Class1'); | ||||||
|  |       const class2 = parser.yy.getClass('Class2'); | ||||||
|  |  | ||||||
|       expect(parser.yy.getClass('Class1').id).toBe('Class1'); |       expect(class1.id).toBe('Class1'); | ||||||
|       expect(parser.yy.getClass('Class02').id).toBe('Class02'); |       expect(class2.id).toBe('Class2'); | ||||||
|       expect(relations[0].relation.type1).toBe('none'); |       expect(relations[0].relation.type1).toBe('none'); | ||||||
|       expect(relations[0].relation.type2).toBe(classDb.relationType.EXTENSION); |       expect(relations[0].relation.type2).toBe(classDb.relationType.REALIZATION); | ||||||
|       expect(relations[0].relation.lineType).toBe(classDb.lineType.LINE); |       expect(relations[0].relation.lineType).toBe(classDb.lineType.LINE); | ||||||
|     }); |     }); | ||||||
|  |  | ||||||
|   | |||||||
| @@ -354,7 +354,7 @@ export const draw = async function (text: string, id: string, _version: string, | |||||||
|   await render( |   await render( | ||||||
|     element, |     element, | ||||||
|     g, |     g, | ||||||
|     ['aggregation', 'extension', 'composition', 'dependency', 'lollipop'], |     ['aggregation', 'extension', 'realization', 'composition', 'dependency', 'lollipop'], | ||||||
|     'classDiagram', |     'classDiagram', | ||||||
|     id |     id | ||||||
|   ); |   ); | ||||||
| @@ -406,6 +406,9 @@ function getArrowMarker(type: number) { | |||||||
|     case 4: |     case 4: | ||||||
|       marker = 'lollipop'; |       marker = 'lollipop'; | ||||||
|       break; |       break; | ||||||
|  |     case 5: | ||||||
|  |       marker = 'realization'; | ||||||
|  |       break; | ||||||
|     default: |     default: | ||||||
|       marker = 'none'; |       marker = 'none'; | ||||||
|   } |   } | ||||||
|   | |||||||
| @@ -121,8 +121,17 @@ line was introduced with 'click'. | |||||||
| <*>"_parent"                    return 'LINK_TARGET'; | <*>"_parent"                    return 'LINK_TARGET'; | ||||||
| <*>"_top"                       return 'LINK_TARGET'; | <*>"_top"                       return 'LINK_TARGET'; | ||||||
|  |  | ||||||
|  | <bqstring>[`]           this.popState(); | ||||||
|  | <bqstring>[^`]+         return "BQUOTE_STR"; | ||||||
|  | <*>[`]                  this.begin("bqstring"); | ||||||
|  |  | ||||||
|  | <*>"_self"              return 'LINK_TARGET'; | ||||||
|  | <*>"_blank"             return 'LINK_TARGET'; | ||||||
|  | <*>"_parent"            return 'LINK_TARGET'; | ||||||
|  | <*>"_top"               return 'LINK_TARGET'; | ||||||
|  |  | ||||||
| <*>\s*\<\|              return 'EXTENSION'; | <*>\s*\<\|              return 'EXTENSION'; | ||||||
| <*>\s*\|\>                      return 'EXTENSION'; | <*>\s*\|\>              return 'REALIZATION'; | ||||||
| <*>\s*\>                return 'DEPENDENCY'; | <*>\s*\>                return 'DEPENDENCY'; | ||||||
| <*>\s*\<                return 'DEPENDENCY'; | <*>\s*\<                return 'DEPENDENCY'; | ||||||
| <*>\s*\*                return 'COMPOSITION'; | <*>\s*\*                return 'COMPOSITION'; | ||||||
| @@ -368,6 +377,7 @@ relation | |||||||
| relationType | relationType | ||||||
|     : AGGREGATION { $$=yy.relationType.AGGREGATION;} |     : AGGREGATION { $$=yy.relationType.AGGREGATION;} | ||||||
|     | EXTENSION   { $$=yy.relationType.EXTENSION;} |     | EXTENSION   { $$=yy.relationType.EXTENSION;} | ||||||
|  |     | REALIZATION { $$=yy.relationType.REALIZATION;} | ||||||
|     | COMPOSITION { $$=yy.relationType.COMPOSITION;} |     | COMPOSITION { $$=yy.relationType.COMPOSITION;} | ||||||
|     | DEPENDENCY  { $$=yy.relationType.DEPENDENCY;} |     | DEPENDENCY  { $$=yy.relationType.DEPENDENCY;} | ||||||
|     | LOLLIPOP    { $$=yy.relationType.LOLLIPOP;} |     | LOLLIPOP    { $$=yy.relationType.LOLLIPOP;} | ||||||
|   | |||||||
| @@ -120,6 +120,18 @@ g.classGroup line { | |||||||
|   stroke-width: 1; |   stroke-width: 1; | ||||||
| } | } | ||||||
|  |  | ||||||
|  | #realizationStart, .realization { | ||||||
|  |   fill: transparent !important; | ||||||
|  |   stroke: ${options.lineColor} !important; | ||||||
|  |   stroke-width: 1; | ||||||
|  | } | ||||||
|  |  | ||||||
|  | #realizationEnd, .realization { | ||||||
|  |   fill: transparent !important; | ||||||
|  |   stroke: ${options.lineColor} !important; | ||||||
|  |   stroke-width: 1; | ||||||
|  | } | ||||||
|  |  | ||||||
| #aggregationStart, .aggregation { | #aggregationStart, .aggregation { | ||||||
|   fill: transparent !important; |   fill: transparent !important; | ||||||
|   stroke: ${options.lineColor} !important; |   stroke: ${options.lineColor} !important; | ||||||
|   | |||||||
| @@ -9,6 +9,8 @@ export const drawEdge = function (elem, path, relation, conf, diagObj) { | |||||||
|     switch (type) { |     switch (type) { | ||||||
|       case diagObj.db.relationType.AGGREGATION: |       case diagObj.db.relationType.AGGREGATION: | ||||||
|         return 'aggregation'; |         return 'aggregation'; | ||||||
|  |       case diagObj.db.relationType.REALIZATION: | ||||||
|  |         return 'realization'; | ||||||
|       case diagObj.db.relationType.EXTENSION: |       case diagObj.db.relationType.EXTENSION: | ||||||
|         return 'extension'; |         return 'extension'; | ||||||
|       case diagObj.db.relationType.COMPOSITION: |       case diagObj.db.relationType.COMPOSITION: | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user