@@ -18,7 +18,7 @@ const BASETAG = "basename-tag";
18
18
const getVaultName = ( ) => window . app . vault . getName ( ) ;
19
19
20
20
/** Create a custom tag node from text content (can include #). */
21
- const createTagNode = ( text : string | null ) => {
21
+ const createTagNode = ( text : string | null , readingMode : boolean ) => {
22
22
const node = document . createElement ( "a" ) ;
23
23
if ( ! text ) return node ;
24
24
@@ -27,7 +27,7 @@ const createTagNode = (text: string | null) => {
27
27
node . target = "_blank" ;
28
28
node . rel = "noopener" ;
29
29
// To comply with colorful-tag css seletor
30
- node . href = `#${ text } ` ;
30
+ node . href = readingMode ? ` ${ text } ` : `#${ text } ` ;
31
31
32
32
const vaultStr = encodeURIComponent ( getVaultName ( ) ) ;
33
33
const queryStr = `tag:${ encodeURIComponent ( text ) } ` ;
@@ -43,12 +43,12 @@ const createTagNode = (text: string | null) => {
43
43
44
44
/** Create a tag node in the type of widget from text content. */
45
45
class TagWidget extends WidgetType {
46
- constructor ( private text : string ) {
46
+ constructor ( private text : string , private readingMode : boolean ) {
47
47
super ( ) ;
48
48
}
49
49
50
50
toDOM ( view : EditorView ) : HTMLElement {
51
- return createTagNode ( this . text ) ;
51
+ return createTagNode ( this . text , this . readingMode ) ;
52
52
}
53
53
}
54
54
@@ -97,7 +97,7 @@ class editorPlugin implements PluginValue {
97
97
node . from - 1 ,
98
98
node . to ,
99
99
Decoration . replace ( {
100
- widget : new TagWidget ( text ) ,
100
+ widget : new TagWidget ( text , false ) ,
101
101
} ) ,
102
102
) ;
103
103
}
@@ -150,7 +150,7 @@ class editorPlugin implements PluginValue {
150
150
currentIndex ,
151
151
currentIndex + tagsArray [ i ] . length ,
152
152
Decoration . replace ( {
153
- widget : new TagWidget ( tagsArray [ i ] ) ,
153
+ widget : new TagWidget ( tagsArray [ i ] , false ) ,
154
154
} ) ,
155
155
) ;
156
156
@@ -182,7 +182,7 @@ export default class TagRenderer extends Plugin {
182
182
node . removeAttribute ( "class" ) ;
183
183
// Hide this node and append the custom tag node in its place.
184
184
node . style . display = "none" ;
185
- node . parentNode ?. insertBefore ( createTagNode ( node . textContent ) , node ) ;
185
+ node . parentNode ?. insertBefore ( createTagNode ( node . textContent , true ) , node ) ;
186
186
} ,
187
187
) ;
188
188
} ) ;
0 commit comments