File tree Expand file tree Collapse file tree 1 file changed +15
-1
lines changed
packages/editor/lib/plugins Expand file tree Collapse file tree 1 file changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -109,9 +109,9 @@ function createDecorations(view, decorations = Decoration.none) {
109109 enter ( node ) {
110110 if ( node . name . startsWith ( 'headline' ) )
111111 headlineRange = { from : node . from , to : node . to }
112- if ( node . name === 'link' ) linkRange = { from : node . from , to : node . to }
113112
114113 if ( node . name === 'link' ) {
114+ linkRange = { from : node . from , to : node . to }
115115 decorations = decorations . update ( {
116116 add : [
117117 // TODO: get the real url
@@ -129,6 +129,20 @@ function createDecorations(view, decorations = Decoration.none) {
129129 } )
130130 }
131131
132+ if ( node . name === 'url' ) {
133+ if ( linkRange === null ) return
134+ // get text of node
135+ const text = view . state . doc . sliceString ( node . from , node . to )
136+ decorations = decorations . update ( {
137+ add : [
138+ Decoration . mark ( {
139+ tagName : 'a' ,
140+ attributes : { class : 'cm-link' , href : text . slice ( 1 , - 1 ) } ,
141+ } ) . range ( linkRange . from , linkRange . to ) ,
142+ ] ,
143+ } )
144+ }
145+
132146 if ( node . name === 'url' || node . name === 'mark' ) {
133147 decorations = decorations . update ( {
134148 add : [ hide ( linkRange ) . range ( node . from , node . to ) ] ,
You can’t perform that action at this time.
0 commit comments