4
4
*/
5
5
6
6
import Component from ' @glimmer/component' ;
7
- import { action } from '@ember/object' ;
8
7
import { assert } from ' @ember/debug' ;
8
+ import { eq } from ' ember-truth-helpers' ;
9
+ import didInsert from ' @ember/render-modifiers/modifiers/did-insert' ;
9
10
10
11
import { TextTagValues , TextAlignValues , TextWeightValues } from ' ./types' ;
11
12
@@ -145,8 +146,7 @@ export default class ShwTextComponent extends Component<ShwTextSignature> {
145
146
return classes .join (' ' );
146
147
}
147
148
148
- @action
149
- addHeadingLink ( element : HTMLHeadingElement ) {
149
+ addHeadingLink = (element : HTMLHeadingElement ) => {
150
150
const innerText = element .innerText ;
151
151
const sanitizedId = innerText
152
152
.trim ()
@@ -172,5 +172,47 @@ export default class ShwTextComponent extends Component<ShwTextSignature> {
172
172
anchor .className = ' shw-page-heading-link' ;
173
173
anchor .setAttribute (' aria-labelledby' , uniqueId );
174
174
element .prepend (anchor );
175
- }
175
+ };
176
+
177
+ <template >
178
+ {{#if ( eq this . tag " h1" ) }}
179
+ <h1 class ={{this .classNames }} ...attributes >{{ yield }} </h1 >
180
+ {{else if ( eq this . tag " h2" ) }}
181
+ <h2
182
+ class ={{this .classNames }}
183
+ {{didInsert this . addHeadingLink}}
184
+ ...attributes
185
+ >{{ yield }} </h2 >
186
+ {{else if ( eq this . tag " h3" ) }}
187
+ <h3
188
+ class ={{this .classNames }}
189
+ {{didInsert this . addHeadingLink}}
190
+ ...attributes
191
+ >{{ yield }} </h3 >
192
+ {{else if ( eq this . tag " h4" ) }}
193
+ <h4
194
+ class ={{this .classNames }}
195
+ {{didInsert this . addHeadingLink}}
196
+ ...attributes
197
+ >{{ yield }} </h4 >
198
+ {{else if ( eq this . tag " h5" ) }}
199
+ <h5
200
+ class ={{this .classNames }}
201
+ {{didInsert this . addHeadingLink}}
202
+ ...attributes
203
+ >{{ yield }} </h5 >
204
+ {{else if ( eq this . tag " h6" ) }}
205
+ <h6
206
+ class ={{this .classNames }}
207
+ {{didInsert this . addHeadingLink}}
208
+ ...attributes
209
+ >{{ yield }} </h6 >
210
+ {{else if ( eq this . tag " p" ) }}
211
+ <p class ={{this .classNames }} ...attributes >{{ yield }} </p >
212
+ {{else if ( eq this . tag " span" ) }}
213
+ <span class ={{this .classNames }} ...attributes >{{ yield }} </span >
214
+ {{else }}
215
+ <div class ={{this .classNames }} ...attributes >{{ yield }} </div >
216
+ {{/if }}
217
+ </template >
176
218
}
0 commit comments