1
- import { TemplateOptions } from "../template" ;
1
+ import { TagStyle , TemplateOptions } from "../template" ;
2
2
import { Commit , CommitRenderOptions , CommitOptions } from "../commit" ;
3
3
import {
4
4
Branch ,
@@ -10,7 +10,12 @@ import { GitgraphCore } from "../gitgraph";
10
10
import { Refs } from "../refs" ;
11
11
import { BranchUserApi } from "./branch-user-api" ;
12
12
13
- export { GitgraphCommitOptions , GitgraphBranchOptions , GitgraphUserApi } ;
13
+ export {
14
+ GitgraphCommitOptions ,
15
+ GitgraphBranchOptions ,
16
+ GitgraphTagOptions ,
17
+ GitgraphUserApi ,
18
+ } ;
14
19
15
20
interface GitgraphCommitOptions < TNode > extends CommitRenderOptions < TNode > {
16
21
author ?: string ;
@@ -26,10 +31,11 @@ interface GitgraphCommitOptions<TNode> extends CommitRenderOptions<TNode> {
26
31
onMouseOut ?: ( commit : Commit < TNode > ) => void ;
27
32
}
28
33
29
- interface GitgraphTagOptions {
34
+ interface GitgraphTagOptions < TNode > {
30
35
name : string ;
31
- ref ?: Commit [ "hash" ] | Branch [ "name" ] ;
32
36
style ?: TemplateOptions [ "tag" ] ;
37
+ ref ?: Commit [ "hash" ] | Branch [ "name" ] ;
38
+ render ?: ( name : string , style : TagStyle ) => TNode ;
33
39
}
34
40
35
41
interface GitgraphBranchOptions < TNode > extends BranchRenderOptions < TNode > {
@@ -113,29 +119,32 @@ class GitgraphUserApi<TNode> {
113
119
*
114
120
* @param options Options of the tag
115
121
*/
116
- public tag ( options : GitgraphTagOptions ) : this;
122
+ public tag ( options : GitgraphTagOptions < TNode > ) : this;
117
123
/**
118
124
* Tag a specific commit.
119
125
*
120
126
* @param name Name of the tag
121
127
* @param ref Commit or branch name or commit hash
122
128
*/
123
129
public tag (
124
- name : GitgraphTagOptions [ "name" ] ,
125
- ref ?: GitgraphTagOptions [ "ref" ] ,
130
+ name : GitgraphTagOptions < TNode > [ "name" ] ,
131
+ ref ?: GitgraphTagOptions < TNode > [ "ref" ] ,
126
132
) : this;
127
133
public tag ( ...args : any [ ] ) : this {
128
134
// Deal with shorter syntax
129
- let name : GitgraphTagOptions [ "name" ] ;
130
- let ref : GitgraphTagOptions [ "ref" ] ;
131
- let style : GitgraphTagOptions [ "style" ] ;
135
+ let name : GitgraphTagOptions < TNode > [ "name" ] ;
136
+ let ref : GitgraphTagOptions < TNode > [ "ref" ] ;
137
+ let style : GitgraphTagOptions < TNode > [ "style" ] ;
138
+ let render : GitgraphTagOptions < TNode > [ "render" ] ;
139
+
132
140
if ( typeof args [ 0 ] === "string" ) {
133
141
name = args [ 0 ] ;
134
142
ref = args [ 1 ] ;
135
143
} else {
136
144
name = args [ 0 ] . name ;
137
145
ref = args [ 0 ] . ref ;
138
146
style = args [ 0 ] . style ;
147
+ render = args [ 0 ] . render ;
139
148
}
140
149
141
150
if ( ! ref ) {
@@ -162,6 +171,7 @@ class GitgraphUserApi<TNode> {
162
171
163
172
this . _graph . tags . set ( name , commitHash ) ;
164
173
this . _graph . tagStyles [ name ] = style ;
174
+ this . _graph . tagRenders [ name ] = render ;
165
175
this . _onGraphUpdate ( ) ;
166
176
return this ;
167
177
}
0 commit comments