File tree Expand file tree Collapse file tree 5 files changed +357
-153
lines changed Expand file tree Collapse file tree 5 files changed +357
-153
lines changed Original file line number Diff line number Diff line change 65
65
const className = el . className . split ( ' ' )
66
66
67
67
if ( className . indexOf ( 'cm-url' ) !== - 1 ) {
68
- const match = / ^ \( ( .* ) \) | \[ ( .* ) \] | ( .* ) $ / . exec ( el . textContent )
68
+ // multiple cm-url because of search term
69
+ const cmUrlSpans = Array . from (
70
+ el . parentNode . getElementsByClassName ( 'cm-url' )
71
+ )
72
+ const textContent =
73
+ cmUrlSpans . length > 1
74
+ ? cmUrlSpans . map ( span => span . textContent ) . join ( '' )
75
+ : el . textContent
76
+
77
+ const match = / ^ \( ( .* ) \) | \[ ( .* ) \] | ( .* ) $ / . exec ( textContent )
69
78
const url = match [ 1 ] || match [ 2 ] || match [ 3 ]
70
79
71
80
// `:storage` is the value of the variable `STORAGE_FOLDER_PLACEHOLDER` defined in `browser/main/lib/dataApi/attachmentManagement`
134
143
return
135
144
}
136
145
137
- const rawHref = e . target . innerText . trim ( ) . slice ( 1 , - 1 ) // get link text from markdown text
146
+ // Create URL spans array used for special case "search term is hitting a link".
147
+ const cmUrlSpans = Array . from (
148
+ e . target . parentNode . getElementsByClassName ( 'cm-url' )
149
+ )
150
+
151
+ const innerText =
152
+ cmUrlSpans . length > 1
153
+ ? cmUrlSpans . map ( span => span . textContent ) . join ( '' )
154
+ : e . target . innerText
155
+ const rawHref = innerText . trim ( ) . slice ( 1 , - 1 ) // get link text from markdown text
138
156
139
157
if ( ! rawHref ) return // not checked href because parser will create file://... string for [empty link]()
140
158
You can’t perform that action at this time.
0 commit comments